<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>-.-</title>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<link rel="stylesheet" href="styles/bootstrap.min.css">

</head>
<body>
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content"></div>
				</div>
			</div>
			<form class="form-inline" role="form"
				action="FurnitureInfo_searchingByKeyMap.action" method="post">
				<div class="form-group">
					<input type="text" id="mykeyword" class="form-control"
						name="keyword" value="<s:property value="#session.keyword" />"
						placeholder="请输入查询家具编号或名称">
				</div>
				<div class="form-group">
					<label for="name">类别</label> <select class="form-control"
						id="categoryid" name="category.id">
						<option value="-1">-请选择-</option>
						<s:iterator value="#session.categoryList">
							<option value='<s:property value="id"/>'
								<s:if test="#session.category.id==id">
											      							selected="selected"
											      						</s:if>><s:property
									value="type" /></option>
						</s:iterator>

					</select>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-info">搜索</button>
				</div>
<%-- 						<%! int i,total; 
								int tem[];
						%>
						<% for(i=1,total=0;i<=100;i++){
							total=total+i;
							tem[i]=total;
						} %>
						<%=tem %> --%>
			</form>
		</div>

		<!--表格-->
		<table class="table table-hover table-condensed">


			<thead class="row">
				<tr>

					<th width="10%">家具编号</th>
					<th width="25%">家居名称</th>
					<th width="10%">图片</th>
					<th width="10%">家具分类</th>
					<th width="10%">是否上架</th>
					<th width="10%">
						<div class="text">
							<div class="bui_select">
								<select id="mypubSelect" class="select" onchange="change()">
									<option>添加时间</option>

									<option value="pubTimdesc"
										<s:if test="#session.groundingKey=='pubTimdesc'">selected="selected"</s:if>>最新发布</option>
									<option value="pubTimeasc"
										<s:if test="#session.groundingKey=='pubTimeasc'">selected="selected"</s:if>>历史发布</option>
								</select>
							</div>
						</div>
					</th>
					<th width="10%">销售价格</th>
					<th width="15%">操作</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="#session.pageBean.list">
					<tr>

						<td><s:property value="furnitureId" /></td>
						<td><s:property value="furnitureName" /></td>
						<td><img src="<s:property value="picture_one"/>"
							height="40dp" width="40dp"></td>
						<td><s:property value="theCategory.type" /></td>
						<td><s:if test="status==1">
		                                		销售中
		                                	</s:if> 
		                                	<s:else>
		                                		已下架
		                                	</s:else></td>
						<td><s:date name="createTime" format="yyy-MM-dd" /></td>
						<td><s:property value="marketPrice" />元</td>
						<td>
							<shiro:hasPermission name="product:list:view">
								 <a href="FurnitureInfo_findFurnitureInfoDetailById.action?furnitureInfo.objId=<s:property value="objId"/>" data-toggle="modal" data-target="#myModal"><span style="padding-right:1em;" class="glyphicon glyphicon-file"></a> 
							</shiro:hasPermission>
							<shiro:hasPermission name="product:list:update">
								<a href="FurnitureInfo_findEditFurnitureInfo.action?furnitureInfo.objId=<s:property value="objId"/>" data-toggle="modal" data-target="#myModal"><span style="padding-right:1em;" class="glyphicon glyphicon-pencil"></a> 
							</shiro:hasPermission>
							<shiro:hasPermission name="product:list:delete">
								<a onclick="delPro(<s:property value="objId"/>)"><span class="glyphicon glyphicon-trash"></span></a>
							</shiro:hasPermission>
							</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>
	<table border="0" cellspacing="0" cellpadding="0" width="900px">
		<tr>
			<td align="right"><span> 第<s:property
						value="#session.pageBean.pageIndex" />/<s:property
						value="#session.pageBean.pageSize" />页
			</span> <span> 总记录数：<s:property value="#session.pageBean.count" />
					每页显示:<s:property value="#session.pageBean.pageCount" /></span> <span>
					<s:if test="#session.pageBean.pageIndex != 1">
						<input type="button" value="首页" class="btn" onclick="Page(1)" />
						<input type="button" value="上一页" class="btn"
							onclick="Page(<s:property value="#session.pageBean.pageIndex-1"/>)" />
					</s:if> <s:if
						test="#session.pageBean.pageIndex != #session.pageBean.pageSize">
						<input type="button" value="下一页" class="btn"
							onclick="Page(<s:property value="#session.pageBean.pageIndex+1"/>)" />
						<input type="button" value="尾页" class="btn"
							onclick="Page(<s:property value="#session.pageBean.pageSize"/>)" />
					</s:if>
			</span></td>
		</tr>
	</table>



	<script type="text/javascript">

	function addPro(){
		window.location='addPro.jsp';
	}
	function editPro(id){
		
	  window.location='FurnitureInfo_findEditFurnitureInfo.action?furnitureInfo.objId='+id; 	
	}
	function delPro(id){
		if(window.confirm("您确认要删除嘛？添加一次不易，且删且珍惜!"+id)){
			window.location="FurnitureInfo_deleteFurnitureInfo.action?furnitureInfo.objId="+id;
		}
	}

	function Page(pageindex) {
	
		var groundingKey=document.getElementById("mypubSelect").value;
		var val=document.getElementById("mykeyword").value;
		var categoryid=document.getElementById("categoryid").value;
		window.location="FurnitureInfo_searchingByKeyMap.action?pageIndex="+pageindex+"&keyword="+encodeURI(encodeURI(val))+"&category.id="+categoryid+"&groundingKey="+groundingKey;
	}
	function search(){
		if(event.keyCode==13){
			var val=document.getElementById("search").value;
/* 			window.location="FurnitureInfo_searchingFurnitureInfo.action?keyword="+encodeURI(encodeURI(val));
 */			window.location="FurnitureInfo_searchingByKeyMap.action?keyword="+encodeURI(encodeURI(val));
			
		}
	}
	function change(){
		var val=document.getElementById("mypubSelect").value;
		window.location="FurnitureInfo_searchingByKeyMap.action?groundingKey="+val;
	}
	
	$('#myModal').on("hide.bs.modal", function(event){
		$(this).removeData("bs.modal");
	});
	
</script>
</body>
</html>
